package com.xsoft.web.action;


import java.util.Date;
import java.util.HashMap;


import com.xsoft.framework.po.Persistent;
import com.xsoft.framework.web.BasicAction;
import com.xsoft.logic.model.sys.User;
import com.xsoft.logic.service.interfaces.sys.module.ModuleService;
import com.xsoft.web.interceptor.ServiceAware;
import com.xsoft.web.interceptor.UserAware;


/**
 * @author 潘冬 2010-8-19 下午04:57:32
 */
public abstract class AdminAction extends BasicAction implements UserAware,
		ServiceAware {
	protected User user; //好像是为了设置公共日志而定义的：因为一个action设置了拦截器，拦截器会设置User；是个比较的做法。
	protected HashMap<String, String> functions = new HashMap<String, String>();
	private ModuleService moduleService;

	public void setUser(User user) {
		this.user = user;
	}

	public User getUser() {
		return user;
	}

	
	/**
	 * 获取模块名称
	 * @author 潘冬
	 * 2010-8-24 上午09:32:30
	 * @return
	 */
	protected String getModulename(){
		String moduleName = this.getText(this.getClass().getName()+".module.name");
		return moduleName;
	}
	
	protected void setVoOperatUser(Persistent vo) {
		vo.getBase().setCreateUser(user.getId());
		vo.getBase().setModUser(user.getId());
		vo.getBase().setAuditUser(user.getId());
		vo.getBase().setPublishUser(user.getId());
		vo.getBase().setAuditTime(new Date());
		vo.getBase().setPublishTime(new Date());
		vo.getBase().setCreateTime(new Date());
		vo.getBase().setLastModTime(new Date());
	}

	protected void initModuleFunction() {
		// TODO Auto-generated method stub
		functions.put("select", "查询");
		functions.put("update", "更新");
		functions.put("insert", "添加");
		functions.put("delete", "删除");
	}
	
}
